<script>
import {getSearchUsers} from "@/api/github";

export default {
  name: "SearchUsers",
  methods:{
    async searchUser(){
      this.$bus.$emit("getUserInfosStart" ,true,true);
      const q = this.$refs.q.value.trim();
      if(!q){
        alert("请输入搜索的关键字！")
        return;
      }
      const {items} = await getSearchUsers(q);
      this.$bus.$emit('getUserInfosEnd',items,false)
    },
  }
}
</script>

<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">Search Github Users</h3>
    <div>
      <input @keydown.enter="searchUser" ref="q" type="text" placeholder="请输入搜索的用户名称">
      <button @click="searchUser">搜索</button>
    </div>
  </section>
</template>

<style scoped>

</style>
